// 条件查询；

const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb://localhost:27017';
// const dbName = 'runoob';
const dbName = 'testmgdb';
const colName = 'userinfo';
//连接 
async function getConnect() {
    try {
        let connct = await MongoClient.connect(url, { useNewUrlParser: true });
        return connct;
    } catch (error) {
        throw error;
    }
}

// CRUD

async function exeFun() {
    let connect = await getConnect();
    let coll = connect.db(dbName).collection(colName);

    let res = await coll.deleteOne({
        where: {
            name: '小不点'
        }
    });
    return res;
}

exeFun().then(res => {
    console.log("delete_res", JSON.stringify(res, null, 4));
}).catch(error => {
    console.log(error);
})